package com.yilin.medical.views;

import java.util.List;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;

import com.yilin.medical.R;

public class RadioGroupContain extends LinearLayout {
	private RadioGroup rg;
	public RadioGroupContain(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
//		this.context = context;
	}

	public RadioGroupContain(Context context, AttributeSet attrs) {
		super(context, attrs);
//		this.context = context;
	}

	public RadioGroupContain(Context context) {
		super(context);
//		this.context = context;
	}
	
	@SuppressLint("NewApi")
	public void init(Activity activity , List<String> list ){
		rg  = (RadioGroup) activity.findViewById(R.id.rg);
		rg.setBackground(null);
		
		for (int i = 0; i < list.size(); i++) {
			RadioButton rb = (RadioButton) View.inflate(activity, R.layout.radiobutton_layout, null);
			rb.setHeight(120);
			rb.setWidth(240);
			rb.setTag(i);
			rb.setText(list.get(i));
			rg.addView(rb);
		}
		
	}

	public void setOnCheckedChangeListener(OnCheckedChangeListener listener){
		rg.setOnCheckedChangeListener(listener);
	}
	public RadioButton getIndex(int index){
		return (RadioButton) rg.getChildAt(index);
	}
	
}